//$(document).ready(function(){
//   var offset = $('.box-lien-he').offset();
//      /* Fixed box-lien-he */
//   $(window).scroll(function() {
//      $('.tooltip-img').remove();
//      var top_y = $(document).scrollTop();
//      var bottom_y = $(document).height() - $(window).height() - top_y;
//      //      console.log(bottom_y);
//      if(top_y>=offset.top){
//         $('.box-lien-he').css({
//            position: 'fixed', 
//            top:0
//         })
//      }else{
//         $('.box-lien-he').css({
//            position: 'relative'
//         })
//      }
//   });
//});
$(document).ready(function(){
   setTimeout(function(){
      /* Set height cho side-bar */
      var max_height = $('.side-bar').height() > $('.main-container').height() ? $('.side-bar').height() : $('.main-container').height();
      $('.side-bar').height(max_height);
      /**/
      var offset = $('.box-lien-he').offset();
      var height_side_bar = $('.side-bar').height();
      var offset_side_bar = $('.side-bar').offset();
      var bottom_side_bar = offset_side_bar.top + height_side_bar;
      var height_lien_he = $('.box-lien-he').height();
      /* Fixed box-lien-he */
      $(window).scroll(function() {
         $('.tooltip-img').remove();
         var top_y = $(document).scrollTop();
         var bottom_lien_he = top_y + height_lien_he;
         var bottom_y = $(document).height() - $(window).height() - top_y;
         var position_lien_he = bottom_side_bar - bottom_lien_he;
         if(position_lien_he > 0)
            position_lien_he = 0;
         if(top_y>=offset.top){
            $('.box-lien-he').css({
               position: 'fixed', 
               top:position_lien_he
            })
         }else{
            $('.box-lien-he').css({
               position: 'relative',
               top:''
            })
         }
      });
   },1000);
});